package com.anysoft.web;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebView;

import com.anysoft.R;
import com.anysoft.event.TimeOutEvent;
import com.anysoft.me.base.BaseWebViewActivity;
import com.anysoft.utils.CommonUtil;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.OnClick;

import static com.anysoft.HostConstant.HOST_WEB_URL_HEADER;
import static com.anysoft.HostConstant.HOST_WEB_URL_HEADER_GYZT;

/**
 * Created by wwq on 2017/3/16.
 * 基金K图横屏
 */

public class FundDetailEchartActivity extends BaseWebViewActivity {

    private String param;
    private String openType;

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideAllTitle();
        ivCancel.setVisibility(View.VISIBLE);
        iv_title_line.setVisibility(View.GONE);
        param = getIntent().getStringExtra("param");
        openType = getIntent().getStringExtra("openType");
        if ("GYZT".equals(openType)) {
            loadUrl = HOST_WEB_URL_HEADER_GYZT + "echarts.html?" + param;
        } else {
            loadUrl = HOST_WEB_URL_HEADER + "echarts.html?" + param;
        }
        if (CommonUtil.isNetWorkConnected(this)) {
            setWebViewConfig(loadUrl);
        }
    }

    @Override
    public void onshouldOverrideUrlLoadingCallBack(WebView webview, String url) {

    }


    @OnClick(R.id.iv_cancel)
    public void onClick() {
        finish();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onTimeOutCallBack(TimeOutEvent event) {
        if (event.isSuccess) {
            finish();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
